#include<bits/stdc++.h>
using namespace std;
int n,i;
struct student
{
	char num;
	char name[300];
	double a,b,c,d;
}s[10000];
void aver(struct student s[]);
void aver_mx(struct student s[]);
bool cmp(student x,student y);
int main()
{
	cin>>n;
	for(i=1;i<=n;i++)
	cin>>s[i].num>>s[i].name>>s[i].a>>s[i].b>>s[i].c;
	aver(s);
	aver_mx(s);
    return 0;
}
void aver(struct student s[])
{
	double yu=0,shu=0,ying=0;
	for(int j=1;j<=n;j++)
	yu=yu+s[j].a,shu=shu+s[j].b,ying=ying+s[j].c;
	printf("%g %g %g\n",yu/n,shu/n,ying/n);
	return;
}
void aver_mx(struct student s[])
{
	double aver_x[10000];
	for(int j=1;j<=n;j++)
	s[j].d=(s[j].a+s[j].b+s[j].c)/3;
	sort(s+1,s+n+1,cmp);
	printf("%c %s %g %g %g",s[1].num,s[1].name,s[1].a,s[1].b,s[1].c);
	return;
}
bool cmp(student x,student y)
{
	return x.d>y.d;
}
